package gdlDao.framework.dao;

import javax.annotation.Resource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

public class GdlSupportDao implements IGdlSupportDao {
	
	private SessionFactory sessionFactory;
	
	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	@Resource(name="sessionFactory")
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}
	
	protected Session getSession() {
		return sessionFactory.getCurrentSession();
	}

	@Override
	public <T> void add(T t) {
		this.getSession().save(t);
	}

	@Override
	public <T> void delete(T t) {
		this.getSession().delete(t);
	}

	@Override
	public <T> void update(T t) {
		this.getSession().update(t);
	}
}
